//
//  BaseViewController.m
//  dzm
//
//  Created by dzmmac on 14-9-25.
//  Copyright (c) 2014年 dzmmac. All rights reserved.
//

#import "BaseViewController.h"
#import "AppColorConfig.h"
#import "SVProgressHUD.h"
@interface BaseViewController () <UIGestureRecognizerDelegate,UINavigationControllerDelegate,UIAlertViewDelegate>
@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    
    [self configNavigationBar];
    self.view.backgroundColor = GLOBLE_BACKGROUND_COLOR;
  
}

// 头部刷新
- (void)addHeader:(void (^)())block tableView:(UITableView *)tableView{
    
    // 设置回调（一旦进入刷新状态，就调用target的action，也就是调用self的loadNewData方法）
    MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
         block();
    }];
    
    // 设置自动切换透明度(在导航栏下面自动隐藏)
    header.automaticallyChangeAlpha = YES;
    
    // 隐藏时间
    header.lastUpdatedTimeLabel.hidden = YES;
    
    // 设置header
    tableView.mj_header = header;
   
}


-(void)configNavigationBar{
    [self.navigationController.navigationBar setTranslucent:NO];
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    [self.navigationController.navigationBar setBarTintColor:GLOBLE_NAVIGATION_COLOR];
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     [UIColor whiteColor], NSForegroundColorAttributeName,
                                                                     [UIFont systemFontOfSize:18], NSFontAttributeName,
                                                                     nil]];
   
}


-(void)panScreenEdgeEnable{
    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc ] init];
    [self.view addGestureRecognizer:pan];
}

-(void)jumperLogin{
    UINavigationController *navi = [[UIStoryboard storyboardWithName:@"User" bundle:nil]  instantiateInitialViewController];
    WEAKSELF
    dispatch_async(dispatch_get_main_queue(), ^{
        [weakSelf presentViewController:navi animated:YES completion:nil];
    });
    
}

- (AppDelegate *)appDelegate {
    return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}


// 隐藏额外的分割线
- (void)setExtraCellLineHidden: (UITableView *)tableView{
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor clearColor];
    [tableView setTableFooterView:view];
}

// 提示框
-(void)showTipViewWithMessage:(NSString *)message{
    
    [[[UIAlertView alloc ] initWithTitle:@""
                                 message:message
                                delegate:nil
                       cancelButtonTitle:@"确定"
                       otherButtonTitles:nil, nil]  show];
}

- (void)didReceiveMemoryWarning{
    [super didReceiveMemoryWarning];
}



@end
